<html>
<head><meta charset="utf-8"><title>custom literals using const generics · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html">custom literals using const generics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="243957732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243957732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243957732">(Jun 25 2021 at 19:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/131828-t-compiler/topic/Pre-pre.20RFC.3A.20track.20possible.20min.20and.20max.20of.20unknown.20values/near/243955103">said</a>:</p>
<blockquote>
<p>+1, I'm much rather see this done as types than as typestate.</p>
<p>Relatedly, I'd love to see someone start looking at how we could do custom literals using const generics, and how close the current state of things is.  I'd love it if <code>foo(2)</code> "just worked" even if <code>foo</code> takes a <code>NonZeroU8</code>.</p>
</blockquote>
<p>so, uhm, I had this discussion with some ppl recently... what if, we made const generics actually be types? So they are ZST types that you can implement traits for. We'd have to add implicit coercion from these ZSTs to their runtime value to not break integers, but everything else could then work as <code>fn foo(i: impl Into&lt;NonZeroU8&gt;)</code>, because you can <code>impl&lt;const C: u8&gt; From&lt;C&gt; for NonZeroU8</code></p>



<a name="243957802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243957802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243957802">(Jun 25 2021 at 19:11)</a>:</h4>
<p>in the compiler we'd get rid of const generics as their own variant of substs, and instead have them as a variant of TyKind</p>



<a name="243957851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243957851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243957851">(Jun 25 2021 at 19:11)</a>:</h4>
<p>this can be done incrementally I believe, so impl wise, we can step really carefully with lots of feature gates for any user visible changes</p>



<a name="243957884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243957884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243957884">(Jun 25 2021 at 19:12)</a>:</h4>
<p>Wouldn't that effectively be <code>struct ConstU8&lt;const N: u8&gt;;</code> and <code>ConstU8::&lt;42&gt;</code>?</p>



<a name="243957993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243957993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243957993">(Jun 25 2021 at 19:12)</a>:</h4>
<p>yes</p>



<a name="243958004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958004">(Jun 25 2021 at 19:12)</a>:</h4>
<p>but without the indirection</p>



<a name="243958020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958020">(Jun 25 2021 at 19:13)</a>:</h4>
<p>and the syntactical noise</p>



<a name="243958080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958080">(Jun 25 2021 at 19:13)</a>:</h4>
<p>would this mean needing to make a TypeId for each const value</p>



<a name="243958083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958083">(Jun 25 2021 at 19:13)</a>:</h4>
<p>hey, this sounds familiar</p>



<a name="243958091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958091">(Jun 25 2021 at 19:13)</a>:</h4>
<p>because that seems pretty problematic</p>



<a name="243958094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958094">(Jun 25 2021 at 19:13)</a>:</h4>
<p>I have used types like those you wrote extensively in a real world project, and they work great, they are just loud</p>



<a name="243958119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958119">(Jun 25 2021 at 19:13)</a>:</h4>
<p>I can see the value in this. It would blur the line between values and types even more, making rust even more of a dependently typed language.</p>



<a name="243958143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958143">(Jun 25 2021 at 19:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="326176">Boxy [she/her]</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/243958080">said</a>:</p>
<blockquote>
<p>would this mean needing to make a TypeId for each const value</p>
</blockquote>
<p>you already got this problem for types like those described by bjorn3</p>



<a name="243958150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958150">(Jun 25 2021 at 19:14)</a>:</h4>
<p>i suppose you already have to for <code>ConstU8&lt;const N: u8&gt;</code></p>



<a name="243958215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958215">(Jun 25 2021 at 19:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="310399">Mara</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/243958083">said</a>:</p>
<blockquote>
<p>hey, this sounds familiar</p>
</blockquote>
<p>sorry, I wanted to send you a link to this immediately then forgot</p>



<a name="243958237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958237">(Jun 25 2021 at 19:14)</a>:</h4>
<p>last week you didn't seem that enthusiastic about this idea, what changed? ^^</p>



<a name="243958241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958241">(Jun 25 2021 at 19:14)</a>:</h4>
<blockquote>
<p>would this mean needing to make a TypeId for each const value</p>
</blockquote>
<p>Only when actually calling <code>type_id::&lt;T&gt;</code>.</p>



<a name="243958324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958324">(Jun 25 2021 at 19:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="310399">Mara</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/243958237">said</a>:</p>
<blockquote>
<p>last week you didn't seem that enthusiastic about this idea, what changed? ^^</p>
</blockquote>
<p>I need to reread that thread, I don't remember being unenthusiastic, maybe curt because I was typing with the on-screen keyboard and a mouse?</p>



<a name="243958344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958344">(Jun 25 2021 at 19:15)</a>:</h4>
<p>I have two hands right now</p>



<a name="243958419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958419">(Jun 25 2021 at 19:16)</a>:</h4>
<p>its because you softened <span class="user-mention" data-user-id="124288">@oli</span> up</p>



<a name="243958437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958437">(Jun 25 2021 at 19:16)</a>:</h4>
<p>haha. i mean that you mostly came with reasons why we wouldn't need this. e.g. that you can just use <code>Num&lt;3&gt;</code> as a type instead of <code>3</code> directly, etc.</p>



<a name="243958510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958510">(Jun 25 2021 at 19:17)</a>:</h4>
<p>hmm... I have been thinking about this all week, so you definitely placed the right seed</p>



<a name="243958521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958521">(Jun 25 2021 at 19:17)</a>:</h4>
<p>:D</p>



<a name="243958531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958531">(Jun 25 2021 at 19:17)</a>:</h4>
<p>I probably just needed to process all the ramnifications</p>



<a name="243958555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958555">(Jun 25 2021 at 19:17)</a>:</h4>
<p>and those for rustc are just :chefkiss:</p>



<a name="243958569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958569">(Jun 25 2021 at 19:17)</a>:</h4>
<p>the language ones are cool, too <span aria-label="stuck out tongue" class="emoji emoji-1f61b" role="img" title="stuck out tongue">:stuck_out_tongue:</span></p>



<a name="243958683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243958683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243958683">(Jun 25 2021 at 19:18)</a>:</h4>
<p>having <code>3</code> be a ZST of the type <code>3</code> could be really interesting for slicing too. <code>v[3..5]</code> could then be a <code>Range&lt;3, 5&gt;</code> instead of a <code>Range&lt;usize, usize&gt;</code>, such that the result can be known to be [T; 2] instead of just [T]</p>



<a name="243965545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243965545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243965545">(Jun 25 2021 at 20:16)</a>:</h4>
<p>yessss</p>



<a name="243981716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243981716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank Steffahn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243981716">(Jun 25 2021 at 23:30)</a>:</h4>
<p>This discussion somehow reminds me of <a href="https://hackage.haskell.org/package/singletons">singletons</a> (a library / pattern for emulating certain aspects of dependent types in Haskell)</p>



<a name="243982308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243982308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank Steffahn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243982308">(Jun 25 2021 at 23:41)</a>:</h4>
<p>I don't necessarily mean that it matters or is too related in any form in detail, it just shares the general approach that ZSTs corresponding to compile-time values can help with.. well.. whatever it can help with, but someone already mentioned dependent types here, too.</p>



<a name="243991484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/243991484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#243991484">(Jun 26 2021 at 03:08)</a>:</h4>
<p>hmm, what if <code>&lt;const N: usize&gt;</code> was just syntax sugar for <code>&lt;N: core::const::Const&lt;usize&gt;&gt;</code>?</p>



<a name="244000264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244000264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244000264">(Jun 26 2021 at 07:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/243957732">said</a>:</p>
<blockquote>
<p>so, uhm, I had this discussion with some ppl recently... what if, we made const generics actually be types?</p>
</blockquote>
<p>Reminds me of the vague <code>const FOO: [u8; impl usize] = include_bytes!(...);</code> conversation, as a way to not promise a specific value, like how using <code>-&gt; impl Iterator&lt;Item = u8&gt;</code> is a way not to promise a particular type.</p>
<p>I don't know if there's a holistic way to think about that.</p>



<a name="244000356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244000356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244000356">(Jun 26 2021 at 07:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/243991484">said</a>:</p>
<blockquote>
<p>hmm, what if <code>&lt;const N: usize&gt;</code> was just syntax sugar for <code>&lt;N: core::const::Const&lt;usize&gt;&gt;</code>?</p>
</blockquote>
<p>Reminds me of <a href="https://www.boost.org/doc/libs/1_76_0/libs/mpl/doc/refmanual/int.html">https://www.boost.org/doc/libs/1_76_0/libs/mpl/doc/refmanual/int.html</a> -- the metaprogramming stuff in C++ Boost wraps values into types so all the generic stuff can work just on types instead of needing versions for types and different versions for values.</p>



<a name="244000505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244000505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244000505">(Jun 26 2021 at 07:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/243957732">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/131828-t-compiler/topic/Pre-pre.20RFC.3A.20track.20possible.20min.20and.20max.20of.20unknown.20values/near/243955103">said</a>:<br>
because you can <code>impl&lt;const C: u8&gt; From&lt;C&gt; for NonZeroU8</code></p>
</blockquote>
<p>Oh, interesting.  I'd been vaguely musing on some sort of </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">FromNumericLiteral</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">BigInteger</span><span class="w"></span>
</code></pre></div>
<p>where <code>FromNumericLiteral</code> is a magic <code>#[non_exhaustive]</code> type that only the compiler can make.</p>
<p>Since I figured different code would want to be able to process the literals in ways that can't be represented in existing types -- like if someone wants to make <code>i256</code> literals.</p>



<a name="244003252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244003252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244003252">(Jun 26 2021 at 08:40)</a>:</h4>
<p>I don't think the compiler will support literals larger than i128 out of various complexity reasons, you'd probably have to go via string literals in that case and do <code>impl&lt;const S: &amp;str&gt; From&lt;S&gt; for MyInt256</code></p>



<a name="244030338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244030338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bot+ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244030338">(Jun 26 2021 at 19:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244003252">said</a>:</p>
<blockquote>
<p>I don't think the compiler will support literals larger than i128</p>
</blockquote>
<p>Would size of widest SIMD register be a reasonable limit?</p>
<p>I have crypto code with const u256s and those string literals look really out of place when everything else is a number.</p>



<a name="244036509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244036509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244036509">(Jun 26 2021 at 22:02)</a>:</h4>
<p>should you write them as u64x4 instead?</p>



<a name="244036514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244036514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244036514">(Jun 26 2021 at 22:03)</a>:</h4>
<p>const my256: avx = [1,2,3,50];<br>
or something</p>



<a name="244041660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244041660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244041660">(Jun 27 2021 at 00:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244003252">said</a>:</p>
<blockquote>
<p>I don't think the compiler will support literals larger than i128 out of various complexity reasons, you'd probably have to go via string literals in that case and do <code>impl&lt;const S: &amp;str&gt; From&lt;S&gt; for MyInt256</code></p>
</blockquote>
<p>I was picturing some large-but-not-huge limit (like was discussed for <code>#</code>s in raw strings) for lexing, since <em>lexing</em> <code>340282366920938463463374607431768211455</code> but not <code>340282366920938463463374607431768211456</code> feels kinda arbitrary to me -- especially when <code>340282366920938463463374607431768211456.0</code> lexes.</p>
<p>But yes, you'd probably have to consume it as a string-like thing via calling a method on a fully-encapsulated type.</p>



<a name="244042870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244042870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244042870">(Jun 27 2021 at 00:57)</a>:</h4>
<div class="codehilite" data-code-language="Haskell"><pre><span></span><code><span class="kr">let</span> <span class="n">x</span> <span class="ow">=</span> <span class="n">fromInteger</span> <span class="mi">340282366920938463463374607431768211456</span> <span class="c1">-- i128 maximum, plus one</span>
</code></pre></div>



<a name="244042996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244042996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244042996">(Jun 27 2021 at 01:02)</a>:</h4>
<p>Ugh I definitely remember seeing an RFC, RFC issue, internals thread, or something similar to this (i.e. unify types and consts). But I can't find it.<br>
Related though: <a href="https://internals.rust-lang.org/t/custom-literals-via-const-generics/14216">custom literals via const generics</a> and <a href="https://github.com/rust-lang/rfcs/pull/2581">generic integers</a></p>
<p>It is a really neat idea.</p>



<a name="244043039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244043039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244043039">(Jun 27 2021 at 01:02)</a>:</h4>
<p>(actually maybe that first one isn't as related as I thought)</p>



<a name="244049239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244049239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244049239">(Jun 27 2021 at 04:32)</a>:</h4>
<p>aren't we dependent on external compiler support for u128 and i128 already?</p>



<a name="244060452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244060452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244060452">(Jun 27 2021 at 10:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="420380">Bot+</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244030338">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244003252">said</a>:</p>
<blockquote>
<p>I don't think the compiler will support literals larger than i128</p>
</blockquote>
<p>Would size of widest SIMD register be a reasonable limit?</p>
<p>I have crypto code with const u256s and those string literals look really out of place when everything else is a number.</p>
</blockquote>
<p>hmm, you mean like RISC-V's Vector extension which can support something like 16kB vectors? &gt;30000 decimal digits seems rather large... though if the compiler were to treat just literals like strings or bigints internally for bigint/bigfloat support, u16::MAX bits seems about right.</p>



<a name="244131353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244131353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244131353">(Jun 28 2021 at 11:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244049239">said</a>:</p>
<blockquote>
<p>aren't we dependent on external compiler support for u128 and i128 already?</p>
</blockquote>
<p>this is just about the literal support. So no need to support the actual value, but e.g. BigInt could get initialized by riddiculous literals. we could probably support any size integer and float literal and make them error out later if used for a too small type, but we'd need to bench it as it is such a common thing to have small lits</p>



<a name="244170684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244170684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244170684">(Jun 28 2021 at 16:28)</a>:</h4>
<p>literals that are out of range for their type are already denied by a lint. if you want custom/overloadable integer literals that can be arbitrarily large, I suggest a new integer literal suffix like <code>x</code> to denote them. the language already reserves the syntax for adding new suffixes to numeric literals</p>



<a name="244357404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244357404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244357404">(Jun 29 2021 at 22:38)</a>:</h4>
<p>Noted.<br>
as Jacob subtly observed, "size of the largest SIMD register" is not a terribly coherent concept. Or at least, not one you want to think about. We have vector ISAs which have specs like "this register is 256-2048 bits, and you find out how many at runtime!"</p>



<a name="244357669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244357669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244357669">(Jun 29 2021 at 22:41)</a>:</h4>
<p>"surely Rust does not compile for those yet" no but it will. <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="244358545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244358545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244358545">(Jun 29 2021 at 22:52)</a>:</h4>
<p>even armv8 has this, no?</p>



<a name="244358838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244358838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244358838">(Jun 29 2021 at 22:55)</a>:</h4>
<p>yes, I was referencing the SVE extension for Arm v8, but it will become commonplace for Arm v9, and LLVM support has been getting along a fair bit.</p>



<a name="244362295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244362295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244362295">(Jun 29 2021 at 23:37)</a>:</h4>
<p>yeah, unfortunately, rust already has a concept of "types whose size you figure out at runtime", and... the way they work in rust seems currently incompatible with efficient compilation to SVE-style simd</p>



<a name="244362642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244362642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244362642">(Jun 29 2021 at 23:43)</a>:</h4>
<p>I'd love it if there was a way to write that in Rust that could use different widths at runtime even on x64 based on runtime detection.  Dunno if that'd be practical, though.</p>



<a name="244362775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244362775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244362775">(Jun 29 2021 at 23:45)</a>:</h4>
<p>every time i've seen it tried it hasn't really worked that well for x86-style simd. part of that has to do with the fact that (at least for float ops) wider registers are a pretty marginal improvement (and can even be a perf hit) compared to an unrolled version of the smaller registers.</p>



<a name="244373425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244373425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244373425">(Jun 30 2021 at 03:20)</a>:</h4>
<p>You don't have to interact with them directly in order to compile to them but yes also that.</p>



<a name="244373568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244373568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244373568">(Jun 30 2021 at 03:24)</a>:</h4>
<p>I will mention again though, aren't SIMD literals better written as just arrays (or array-like syntax) of normal-sized literals?</p>



<a name="244373586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244373586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244373586">(Jun 30 2021 at 03:25)</a>:</h4>
<p>I mean regardless of how many f32 lanes you have, each is an f32, and each can be individually parsed as such out of the source code.</p>



<a name="244373731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244373731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244373731">(Jun 30 2021 at 03:28)</a>:</h4>
<p>yeah, i agree. i dont think simd needs literal syntax</p>



<a name="244373759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244373759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244373759">(Jun 30 2021 at 03:29)</a>:</h4>
<p>now what would be useful to add literal support for is Wrapping&lt;{integer}&gt; and NonZero[int_type]</p>



<a name="244373805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244373805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244373805">(Jun 30 2021 at 03:30)</a>:</h4>
<p>for sure</p>



<a name="244379502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244379502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244379502">(Jun 30 2021 at 05:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244373568">said</a>:</p>
<blockquote>
<p>I will mention again though, aren't SIMD literals better written as just arrays (or array-like syntax) of normal-sized literals?</p>
</blockquote>
<p>Yeah, at most a <code>simd[1, 2, 3, 4]</code> or something.</p>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244373759">said</a>:</p>
<blockquote>
<p>now what would be useful to add literal support for is Wrapping&lt;{integer}&gt; and NonZero[int_type]</p>
</blockquote>
<p>Those were definitely the most pressing kinds of example, to me.</p>



<a name="244455951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/244455951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#244455951">(Jun 30 2021 at 17:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics/near/244379502">said</a>:</p>
<blockquote>
<p>Yeah, at most a <code>simd[1, 2, 3, 4]</code> or something.</p>
</blockquote>
<p>Oops, I meant <code>simd![1, 2, 3, 4]</code> here.</p>



<a name="245627872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/custom%20literals%20using%20const%20generics/near/245627872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/custom.20literals.20using.20const.20generics.html#245627872">(Jul 11 2021 at 21:21)</a>:</h4>
<p>faking huge literals using macros: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=60fb20ccb00dcd8b5bd7ff08392874c4">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=60fb20ccb00dcd8b5bd7ff08392874c4</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>